<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{$title}</title>
<include file='web/common:source'/>
<style>
div.layui-layer-shade{background-color:rgba(255,255,255,0) !important;}
div.layui-layer-rim{border:none; box-shadow:3px 5px 6px #dadada,-3px -1px 6px #dadada;}
div.layui-layer-title{background-color:#e2e5e8;}
</style>
</head>
<body ng-app="myApp" ng-controller="myAppControl">
<div class="mainBox m o">
    <div class="mainRight fr" style="padding-bottom:0px;">
        <include file='web/common:header'/>
        <div class="mainRightBot pr o">
            <!-- leftMenu start -->
            <include file='web/common:left'/>
            <!-- leftMenu end -->
            <div class="rightBox fr" style="width:940px; min-height:900px; background:#f1f1f1;">            	
            	<div class="jifenListBox m" style="width:860px; margin-top:40px; background:#fff;">
            		<div class="rightBoxBotTop o afl">
						<a href="{:U('User/index')}">返回上一级</a>
						<a href="{:U('User/index')}" class="ts300">个人中心</a>
						<a class="lt"><i class="layui-icon" style="font-size: 16px;">&#xe602;</i></a>
						<a href="javascript:;" class="ts300"><if condition="$_GET['type'] eq 1">积分明细<else/>领取积分</if></a>
	            	</div>
	            	<style type="text/css">
					div.jifenLingqu dl.ziyuanList dt.fl span{font-size:16px;}
					div.jifenLingqu dl.ziyuanList dt.fl div{font-size:16px; color:#9A9A9A; padding-top:10px;}
					div.jifenLingqu dd.fr a.hasBg{background:#3296F3; color:#fff; padding:5px 15px; margin-right:15px; border-radius:5px;}					
	            	</style>
					<div class="ziyuanList jifenLingqu m o" style="width:800px;padding-bottom: 30px;">
						<!-- ziyuanListHover -->
						<foreach name="data['list']" item="x">
					    <dl class="ziyuanList o" style="padding-bottom:25px;">
					        <dt class="fl">
					            <a class="ts300">{$x.project_name}</a>
					            <span>获得积分：<font style="color:red;">{$x.points}分</font></span>
					            <div>分配人：{$x.user_name}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$x.created_at}</div>
					            <if condition="$_GET['type'] eq 1 && $x['status'] eq 2">
					            <div>申诉原因：{$x.refuse_reason}</div>
					            </if>
					        </dt>
					        <dd class="fr o" style="height:40px; margin-top:10px;">
					        	<if condition="$x['status'] eq 0">
						            <a href="javascript:;" ng-click="confirmBtn({$x.id},1)" class="b fl hasBg">确认领取</a>
						            <a href="javascript:;" ng-click="confirmBtn({$x.id},2)" class="b fr hasBg">拒绝领取</a>
						        <elseif condition="$x['status'] eq 1"/>									
						            <a class="b fr">已确认</a>
						        <elseif condition="$x['status'] eq 2"/>
						        	<a class="b fr" style="color:red;">已申述</a>
						        <else />
						        	<a class="b fr"></a>
					            </if>
					        </dd>
					        <dd class="line ts300"></dd>
					    </dl>
					    </foreach>
					    <div id="pageNext" class="m Pagination" style="width:766px; padding:30px 0px 30px;">
							{$data['show']}
	                    </div>
					</div>									
				</div>
				<script type="text/javascript">
				(function(){
				    $("div.ziyuanList dl.ziyuanList").click(function(){
				        if($(this).hasClass('ziyuanListHover')){
				            $(this).removeClass('ziyuanListHover');
				        }else{
				            $(this).addClass('ziyuanListHover');
				        };                            
				    });
				})();
				</script>
                <!-- 新建订单 弹出层 start -->
                <include file='web/common:createDingdan'/>
                <!-- 新建订单 弹出层 end -->
                <!-- 新建项目 弹出层 新建项目 start -->
                <include file='web/common:createProject'/>
                <!-- 新建项目 弹出层 end -->
                <!-- 新建合同 弹出层 start -->
                <include file='web/common:createHetong'/>
                <!-- 新建合同 弹出层 end -->
            </div>
        </div>
    </div>
</div>
</body>
<include file='web/common:footer'/>
<script type="text/javascript">
// angular start
var hostUrl = "http://"+"<?php echo $_SERVER['HTTP_HOST']; ?>/";
var confirmJifenUrl = hostUrl+"user/confirmPoints"; // 领取积分和拒绝领取的接口
angular.module("myApp",[]).controller('myAppControl',['$scope',function($scope){
    $scope.confirmBtn = function(curId,type){
    	console.log(curId);
    	console.log(type);
    	if(type == 1){
    		layer.confirm('你确定要领取吗？',{
	    		btn: ['确定','取消']
	    	},function(index){
	    		$.post(confirmJifenUrl,{id:curId,type:type},function(res){
	    			if(res.message == "OK"){
	    				layer.alert("领取积分成功");
	    				location.reload();
	    			}else{
	    				layer.alert(res.message);
	    			};
	    		},'json');
	    		layer.close(index);
	    	}); 
    	}else if(type == 2){
    		layer.prompt({
				formType: 2,
				value: null,
				title: '请输入拒绝领取的理由',
				area: ['300px', '100px'] //自定义文本域宽高
    		},function(val, index){
				layer.msg('得到了'+val);
				if(val == "" || val == null){return false;};
				$.post(confirmJifenUrl,{id:curId,type:type,reason:val},function(res){
					if(res.message == "OK"){
	    				layer.alert("拒绝领取积分成功");
	    				location.reload();
	    			}else{
	    				layer.alert(res.message);
	    			};
				},'json');
				layer.close(index);
			});
    	}else{
    		layer.alert('参数错误');
    	};
    		
    };
}]);
</script>
</html>